<!DOCTYPE html>
<html lang="en-US">
  <head>
    <link href="/assets/index.css" rel="stylesheet" type="text/css" />
    <script crossorigin="anonymous" src="https://unpkg.com/react@16.8.6/umd/react.production.min.js"></script>
    <script crossorigin="anonymous" src="https://unpkg.com/react-dom@16.8.6/umd/react-dom.production.min.js"></script>
    <script crossorigin="anonymous" src="/test-harness.js"></script>
    <script crossorigin="anonymous" src="/test-page-object.js"></script>
    <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
    <script
      crossorigin="anonymous"
      src="https://unpkg.com/react-dom@16.8.6/umd/react-dom-test-utils.production.min.js"
    ></script>
  </head>
  <body>
    <main id="webchat"></main>
    <script>
      run(async function () {
        WebChat.renderWebChat(
          {
            directLine: WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() }),
            store: testHelpers.createStore()
          },
          document.getElementById('webchat')
        );

        // GIVEN: An "input" card is shown and the focus is on the transcript and the card input activity.
        await pageConditions.uiConnected();
        await pageObjects.sendMessageViaSendBox('card inputs');
        await pageConditions.numActivitiesShown(2);
        await pageConditions.scrollStabilized();
        await pageConditions.became(
          'focus is on the send box',
          () => document.activeElement === pageElements.sendBoxTextBox(),
          1000
        );
        await host.sendShiftTab(3);
        await pageConditions.became(
          'focus is on the input card',
          () => pageElements.focusedActivity() === pageElements.activities()[1],
          1000
        );
        await pageConditions.scrollStabilized();

        // WHEN: ENTER key is pressed.
        await host.sendKeys('ENTER');

        // THEN: The first text box in the input card should be focused.
        await pageConditions.became(
          'focus is on the first text box in the input card',
          () => document.activeElement === document.querySelector('.ac-input ,ac-textInput'),
          1000
        );

        await host.snapshot();
      });
    </script>
  </body>
</html>
